{template 'common'}
{php load()->func('tpl')}
<input type="hidden" name="reply_id" value="{$reply['id']}" />
    <div class="panel panel-default">
            <div class="panel-heading">
                基本信息 
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">活动名称</label>
                    <div class="col-xs-12 col-sm-9">
                         <input type="text" class="form-control" placeholder="" name="title" value="{$reply['title']}" />
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">活动封面</label>
                    <div class="col-xs-12 col-sm-9">
                         {php echo tpl_form_field_image('thumb',$reply['thumb']);}
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">活动简介</label>
                    <div class="col-xs-12 col-sm-9">
                         <textarea style="height:70px;" class="form-control" id="description" name="description" cols="70">{$reply['description']}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">活动时间</label>
                    <div class="col-xs-12 col-sm-9">
                          {php echo tpl_form_field_daterange('datelimit',array('starttime'=>date('Y-m-d H:i',$reply['starttime']),'endtime'=>date('Y-m-d H:i',$reply['endtime'])), true)}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">关注引导页</label>
                    <div class="col-xs-12 col-sm-9">
                         <input type="text" class="form-control" placeholder="" name="follow_url" value="{$reply['follow_url']}" />
                    </div>
                </div>
                   <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">分享跳转</label>
                    <div class="col-xs-12 col-sm-9">
                         <input type="text" class="form-control" placeholder="" name="share_url" value="{$reply['share_url']}" />
                         <span class="help-block">分享后跳转的页面</span>
                    </div>
                </div>
               
            </div>
      
            <div class="panel-heading">
                样式设置  <small>根据自己实际情况进行修改, 全部使用png透明图片</small>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">背景图片</label>
                    <div class="col-xs-12 col-sm-9">
                      {php echo tpl_form_field_image('bgimg',$reply['bgimg']);}
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">启动图片</label>
                    <div class="col-xs-12 col-sm-9">
                      {php echo tpl_form_field_image('titleimg',$reply['titleimg']);}
                    </div>
                </div>
                 <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">帮助图片</label>
                    <div class="col-xs-12 col-sm-9">
                      {php echo tpl_form_field_image('helpimg',$reply['helpimg']);}
                    </div>
                </div>
                   <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">相机图片</label>
                    <div class="col-xs-12 col-sm-9">
                      {php echo tpl_form_field_image('cameraimg',$reply['cameraimg']);}
                    </div>
                </div>
                      <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">数字图片</label>
                    <div class="col-xs-12 col-sm-9">
                      {php echo tpl_form_field_image('numberimg',$reply['numberimg']);}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">分享引导图片</label>
                    <div class="col-xs-12 col-sm-9">
                      {php echo tpl_form_field_image('shareimg',$reply['shareimg']);}
                    </div>
                </div>
            </div>
       
            <div class="panel-heading">
                照片设置 
            </div>
            <div class="panel-body">
               
                <div class="form-group">
     
            <div class="col-sm-9 col-xs-12">
                 
                        <table class='table'>
                            <thead>
                                <tr>
                                    <th>图片</th>
                                    <th>分数倍数</th>
                                    <th>出现概率(%)</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody id="item-items">
                                {loop $items $item}
                                    {template 'item_item'}
                                {/loop}
                            </tbody>
                        </table>
                    
                 <a class="btn btn-default btn-add-field" href="javascript:;" onclick="addItem();"><i class="fa fa-plus" title="添加照片"></i> 添加照片</a>
                 <span class="help-inline">概率相加必须为100</span>
            </div>
        </div>
                
                
                </div>
        
                     
         <div class="panel-heading">
                分享设置
            </div>
            <div class="panel-body">
                  <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">分享标题</label>
                    <div class="col-xs-12 col-sm-9">
                         <input type="text" class="form-control" placeholder="" name="share_title" value="{$reply['share_title']}" />
                          <span class='help-block'>例如: 我得了 [SCORE] 分，其中 [SCORE] 会替换得分</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">分享图标</label>
                    <div class="col-xs-12 col-sm-9">
                      {php echo tpl_form_field_image('share_icon',$reply['share_icon']);}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">分享描述</label>
                    <div class="col-xs-12 col-sm-9">
                         <textarea style="height:70px;" class="form-control" id="share_desc" name="share_desc" cols="70">{$reply['share_desc']}</textarea>
                         <span class='help-block'>例如: 我得了 [SCORE] 分，其中 [SCORE] 会替换得分</span>
                    </div>
                </div>
            </div>
        
        
        </div>
                
 
 
<script text="text/javascript">
 $('form').submit(function(){
     
     var rate = 0;
     if($(".item_item").length<=0){
         alert('至少添加一张照片');
         return false;
     }
     $(".rate").each(function(){
         rate+=parseFloat( $(this).val() );
     });
     
     if(isNaN(rate) || rate!=100){
         alert('照片出现概率相加必须为 100!');
         return false;
     }
     return true;
     
 })
     function addItem(){
        $(".btn-add-item").button("loading");
           $.ajax({
               url: "{php echo $this->createWebUrl('tpl',array('t'=>'item_item'))}",
               cache:false
           }).done(function(html){
               $(".btn-add-item").button("reset");
              $("#item-items").append(html);
         });
    }
    function removeItem(obj){
        $(obj).parent().parent().remove();
    }
    
</script>

